package oop8;

/**
 * @author oldliu
 * @since 1.0
 */
//三角形
public class Triangle extends Shape {
    private double l1;
    private double l2;
    private double l3;

    public Triangle() {
    }

    public Triangle(double l1, double l2, double l3) {
        this.l1 = l1;
        this.l2 = l2;
        this.l3 = l3;
    }

    public double getL1() {
        return l1;
    }

    public void setL1(double l1) {
        this.l1 = l1;
    }

    public double getL2() {
        return l2;
    }

    public void setL2(double l2) {
        this.l2 = l2;
    }

    public double getL3() {
        return l3;
    }

    public void setL3(double l3) {
        this.l3 = l3;
    }

    @Override
    public double calcArea() {
        double p=calcPerimeter()/2;
        return Math.sqrt((p-l1)*(p-l2)*(p-l3)*p);
    }

    @Override
    public double calcPerimeter() {
        return l1+l2+l3;
    }

    @Override
    public String toString() {
        return "三角形，三边分别是"+l1+","+l2+","+l3;
    }
}
